package com.nekonomics
package domain.auxiliary

import types.UserRole
import types.UserRole.*

import com.nekonomics.domain.entity.User
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonCodec, JsonEncoder}

case class UserView (
  id: Long,
  email: String,
  nickname: String,
  role: UserRole = Seller,
  avatarUrl: Option[String] = None
) derives JsonCodec

object UserView {
  def of(user: User): UserView = {
    UserView(
      id = user.id,
      email = user.email,
      nickname = user.nickname,
      role = user.role,
      avatarUrl = user.avatarUrl
    )
  }
}
